package com.zr.service.base.impl;

import java.util.Date;
import java.util.List;
import javax.annotation.Resource;
import com.zr.vo.base.BaseCustomer;
import com.github.pagehelper.PageInfo;
import com.zr.dao.base.BaseCustomerDao;
import com.github.pagehelper.PageHelper;
import org.springframework.stereotype.Service;
import com.zr.service.base.BaseCustomerService;

/**
 * 委托客户增删改查实现类
 */
@Service
public class BaseCustomerServiceImpl implements BaseCustomerService {

    @Resource
    private BaseCustomerDao baseCustomerDao;

    /**
     * 条件查询委托客户信息列表
     * @param baseCustomer
     * @return
     * @author liutienan
     */
    @Override
    public PageInfo<BaseCustomer> getList(BaseCustomer baseCustomer) {
        PageHelper.startPage(baseCustomer.getPageNum(), baseCustomer.getPageSize());
        PageInfo<BaseCustomer> pageInfo=new PageInfo<BaseCustomer>(baseCustomerDao.getList(baseCustomer));
        return pageInfo;
    }

    /**
     * 查询所有委托客户信息列表
     * @return
     * @author liutienan
     */
    @Override
    public List<BaseCustomer> listAll() {
        return baseCustomerDao.listAll();

    }

    /**
     * 新增委托用户
     * @param baseCustomer
     * @return
     * @author liutienan
     */
    @Override
    public int add(BaseCustomer baseCustomer) {
        baseCustomer.setCreateTime(new Date());
        return baseCustomerDao.insertSelective(baseCustomer);
    }

    /**
     * 修改委托用户
     * @param baseCustomer
     * @return
     * @author liutienan
     */
    @Override
    public int edit(BaseCustomer baseCustomer) {
        baseCustomer.setModifyTime(new Date());
        return baseCustomerDao.updateByPrimaryKeySelective(baseCustomer);
    }

    /**
     * 删除委托用户
     * @param id
     * @return
     * @author liutienan
     */
    @Override
    public int remove(Integer id) {
        return baseCustomerDao.deleteByPrimaryKey(id);
    }


}
